package com.itheima.mapper;

import com.itheima.domain.Item;
import com.itheima.domain.Order;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

public interface OrdersMapper {

    @Select("select * from orders where user_id=#{id}")
    @Results({
            @Result(id=true,column = "id",property = "id"),
            @Result(column = "number",property = "number"),
            @Result(
                    property = "itemList",
                    javaType = List.class,
                    column = "id",
                    many = @Many(select = "com.itheima.mapper.ItemsMapper.findByOid",fetchType = FetchType.EAGER)
            )
    })
    List<Order> findByUid(int id);
}
